<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition   xmlns="http://www.w3.org/1999/xhtml"
			      xmlns:h="http://java.sun.com/jsf/html"
				  xmlns:p="http://primefaces.org/ui"
			      xmlns:f="http://java.sun.com/jsf/core"
			      xmlns:ui="http://java.sun.com/jsf/facelets"
			      >  
   <p:panel header="Search Options" toggleable="true" toggleOrientation="vertical" collapsed="false">  
   		<p:panelGrid columns="6" style="margin-bottom:10px;font-size:14px;" cellpadding="5">  
  		<f:facet name="header">  
        
    	</f:facet>  
          
          <h:outputText value="Region: " /> 
        <p:selectOneMenu style="width:170px" value="#{stockUpdateManagedBean.region}">   
        	<f:selectItem itemLabel="--Select Region--" itemValue="" />   
            <f:selectItems value="#{servicesManagedBean.regionList}" />  
            <p:ajax update="mycountries" listener="#{stockUpdateManagedBean.updateCountries}" />
        </p:selectOneMenu>
  
        <h:outputText value="Country: " /> 
        <p:selectOneMenu style="width:180px" id="mycountries" value="#{stockUpdateManagedBean.country}">
        	<f:selectItem itemLabel="--Select Country--" itemValue="" />     
            <f:selectItems value="#{stockUpdateManagedBean.countriesList}" />  
        </p:selectOneMenu>      
         
         <p:column colspan="7">  
        <p:commandButton value="GO" update="StocksdataTable @form" action="#{stockUpdateManagedBean.updateList}" />
        </p:column> 
        
        <h:commandLink rendered="#{stockUpdateManagedBean.methodCalled}">  
        <p:graphicImage value="NWDSAKMS-excel-logo.png" width="30" height="30" title="Export to Excel"  style="border:0;margin-left:5px"/>  
        <p:dataExporter type="xls" target="StocksdataTable" fileName="Stock_Status_#{servicesManagedBean.dateNow}" />  
    	</h:commandLink>   
    </p:panelGrid>
    
</p:panel>

<p:panel id="StocksdataTableP">
<p:dataTable id="StocksdataTable" rendered="#{stockUpdateManagedBean.methodCalled}"
			 style="margin-top:5px" 
			 var="stock" 
			 value="#{stockUpdateManagedBean.slist}" 
			 paginator="true" 
			 rows="16" 
			 paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
			 rowsPerPageTemplate="15,30,45" 
			 sortOrder="descending" 
			 lazy="true"
			 sortBy="#{stock.createddate.day}" 
			 >  
        <f:facet name="header">  
            Stock Update Status  
        </f:facet> 
        
                <p:column width="110">
        <f:facet name="header" >  
                    Region
            </f:facet>  
            <h:outputText value="#{stock.region}"/> 
        </p:column>
        
        <p:column width="115">  
            <f:facet name="header" >  
                    Country 
            </f:facet>  
            <h:outputText value="#{stock.country}"/> 
        </p:column> 
           
           		<p:column width="170">
        <f:facet name="header" >  
                    Distributor ID
            </f:facet>  
            <h:outputText value="#{stock.distributorid}"/> 
        </p:column>  
           
        <p:column width="260">
        <f:facet name="header" >  
                    Created Date Timestamp 
            </f:facet>  
            <h:outputText value="#{stock.createddateTimestamp}"/> 
        </p:column>  
        

   		
   		<p:column width="115">
        <f:facet name="header" >  
                    GUI No.
            </f:facet>  
            <h:outputText value="#{stock.guino}"/> 
        </p:column>
        
        
        <p:column width="160">
        <f:facet name="header" >  
                    Reporting Date
            </f:facet>  
            <h:outputText value="#{stock.reportingdate}"/> 
        </p:column>
        
          <p:summaryRow>
		<p:column colspan="6" >    
            </p:column> 
        </p:summaryRow>
        
    </p:dataTable>
    </p:panel>
</ui:composition>